package com.wgz.medicalmanagement.domain.entity;

import java.io.Serializable;
import java.time.LocalDateTime;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import lombok.Data;

/**
 * 角色权限关联实体类
 * 
 * @author medical
 * @since 2023-05-29
 */
@Data
@Entity
@Table(name = "role_permissions")
@TableName("role_permissions")
public class RolePermission implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 主键ID
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 角色ID
     */
    @Column(name = "role_id")
    @TableField("role_id")
    private Long roleId;

    /**
     * 权限ID
     */
    @Column(name = "permission_id")
    @TableField("permission_id")
    private Long permissionId;

    /**
     * 关联角色实体
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "role_id", insertable = false, updatable = false)
    @TableField(exist = false)
    private Role role;

    /**
     * 关联权限实体
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "permission_id", insertable = false, updatable = false)
    @TableField(exist = false)
    private Permission permission;

    /**
     * 创建时间
     */
    @Column(name = "created_time")
    @TableField("created_time")
    private LocalDateTime createdTime;
} 